import yaml
from aiohttp import ClientSession


class Crawler:

    def __init__(self):
        self.cfg = yaml.safe_load(open('../config.yml', 'rb'))
        self.url = self.cfg['url']
        self.ua = self.cfg['ua']
        self.proxy = self.cfg['proxy']

    async def scraper(self):
        offset = 1
        skus = []

        while True:
            url = self.url.replace('num', f'{offset}')

            async with ClientSession() as s:
                async with s.get(url, headers=self.ua) as r:
                    status = r.status
                    print(r.text())
                    #page = await r.json()
                    print(url)
                    print(status)

            offset += 1
            if offset == 10:
                break
